﻿package net.wangit.dev;

import net.wangit.LabelUtil;
import net.wangit.context.ActionContext;
import net.wangit.jdbc.DB;
import net.wangit.jdbc.util.DBHelper;
import net.wangit.support.action.DefaultAction;
import net.wangit.util.Checker;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class DomainAction extends DefaultAction {

	private static final Log log = LogFactory.getLog(DomainAction.class);
	protected String domain;

	public DomainAction() {
	}

	protected DB getDB(ActionContext ac) {
		domain = ConsoleDomainUtil.getDomain(ac);
		if (log.isDebugEnabled())
			log.debug((new StringBuilder("server domain=")).append(domain)
					.toString());
		if (Checker.isEmpty(domain)) {
			log.error("could not find domain!");
			ac.getActionResult().addInfo(LabelUtil.get(ac, "dev", DLD.TIMEOUT));
			return null;
		} else {
			return DBHelper.getDomainDB(domain);
		}
	}

}
